package com.general.framework.service.impl;

import com.general.framework.entity.UserRole;
import com.general.framework.mapper.UserRoleMapper;
import com.general.framework.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public List<String> getRolesByUserId(Long userId) {
        return userRoleMapper.getRolesByUserId(userId);
    }

    // @Override
    // public void saveUserRoles(Long userId, List<Long> roleIds) {
    //     // 删除原有的用户角色关联关系
    //     userRoleMapper.deleteByUserId(userId);
    //
    //     // 插入新的用户角色关联关系
    //     if (roleIds != null && !roleIds.isEmpty()) {
    //         for (Long roleId : roleIds) {
    //             UserRole userRole = new UserRole();
    //             userRole.setUserId(userId);
    //             userRole.setRoleId(roleId);
    //             userRoleMapper.insert(userRole);
    //         }
    //     }
    // }
}